package com.itboye.mengwu.data.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.app.ui.main.MainPresenter;
import com.itboye.mengwu.data.interfaces.IProductAsk;
import com.itboye.mengwu.data.model.ProductAskModel;
import com.itboye.mengwu.data.repository.ProductAskRepository;

public class ProductAskPresenter extends BasePresenter implements IProductAsk {
	public static final String ASK_success = MainPresenter.class.getName()
			+ "_ASK_success";
	public static final String ASK_fail = MainPresenter.class.getName()
			+ "_ASKE_fail";
	public static final String ASKsave_success = MainPresenter.class.getName()
			+ "_ASKsave_success";
	public static final String ASKsave_fail = MainPresenter.class.getName()
			+ "_ASKsave_fail";

	public ProductAskPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(ProductAskModel model) {
		// TODO Auto-generated method stub
		IProductAsk ask = new ProductAskRepository(new ICompleteListener() {

			@Override
			public void success(ResultEntity result) {
				// TODO Auto-generated method stub
				result.setEventTag(Tag_Success);
				result.setEventType(ASKsave_success);
				ProductAskPresenter.this.setChanged();
				ProductAskPresenter.this.notifyObservers(result);
			}

			@Override
			public void failure(ResultEntity result) {
				// TODO Auto-generated method stub
				result.setEventTag(Tag_Success);
				result.setEventType(ASKsave_fail);
				ProductAskPresenter.this.setChanged();
				ProductAskPresenter.this.notifyObservers(result);
			}
		});
		ask.add(model);
	}

	@Override
	public void delete(ProductAskModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(ProductAskModel model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(ProductAskModel model) {
		// TODO Auto-generated method stub
		IProductAsk ask = new ProductAskRepository(new ICompleteListener() {

			@Override
			public void success(ResultEntity result) {
				// TODO Auto-generated method stub
				result.setEventTag(Tag_Success);
				result.setEventType(ASK_success);
				ProductAskPresenter.this.setChanged();
				ProductAskPresenter.this.notifyObservers(result);
			}

			@Override
			public void failure(ResultEntity result) {
				// TODO Auto-generated method stub
				result.setEventTag(Tag_Success);
				result.setEventType(ASK_fail);
				ProductAskPresenter.this.setChanged();
				ProductAskPresenter.this.notifyObservers(result);
			}
		});
		ask.getInfo(model);
	}

	@Override
	public List<ProductAskModel> queryYouHuiQuan(ProductAskModel model) {
		// TODO Auto-generated method stub
		return null;
	}

}
